package com.example.jikeyoujikeyou.office_sz.view.base;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.example.jikeyoujikeyou.office_sz.comment.utils.ListValidate;

import java.util.List;

public class BasePagerAdapter extends PagerAdapter {

    private List<View> viewList;

    public BasePagerAdapter(List<View> viewList) {
        this.viewList = viewList;
    }

    @Override
    public int getCount() {
        return ListValidate.isEmpty(viewList) ? 0 : viewList.size() ;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view  == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(viewList.get(position));
        return viewList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(viewList.get(position));
    }



}
